/* Copyright (C) 2009 Alvaro Morais <alvaromorais@gmail.com>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details at
 * http://www.gnu.org/copyleft/gpl.html
 */

#ifndef BFILE_H
#define BFILE_H

#include <string>
#include <sys/stat.h>
#include <sys/types.h>

using namespace std;

class BFile
{
public:
    BFile(const string& _filename);
    BFile();
    void reCheck();
    void assignFilename(const string& _filename);
    string getLongFilename() const;

    bool IsVisible() const;
    bool IsReadable() const;
    bool IsWritable() const;
    bool IsExecutable() const;
    bool IsDirectory() const;
    bool IsRegular() const;
    bool IsBlockSpecial() const;
    bool IsCharSpecial() const;
    bool IsFifoSpecial() const;
    bool IsSymbolicLink() const;
    bool IsSocket() const;

    string BaseName() const;
    string DirName() const;

    bool IsSet() const;

    static string ExtractDirName(const string& _filename);
    static string ExtractBaseName(const string& _filename);
private:
    string long_filename;
    string dirName;
    string baseName;

    mode_t fileMode;

    inline void calculateBaseName();
    inline void calculateDirName();
    inline void setFileMode();
    bool isSet;

};

#endif // BFILE_H
